<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>招募会员</title>
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/mall.css" />
	</head>

	<body>
		<div class="mui-content" id="m1">
			

			<div class="mui-content record_content" style="margin: 7px 5px ;background-color: #fff;">
				<p style="width:90%;margin-left:5%;padding:7px;border-bottom: 1px #CCCCCC solid;">付款金额</p>
				<p><em style="width:90%;margin-left:5%;height: 40px;line-height:40px;font-size: 28px;font-weight: bold;color: black;">￥</em>
					<input id="hbmoney" onkeyup="value=value.replace(/[^\d\.]/g,'')" value="998" placeholder="请输入消费金额" style="border: none;height: 40px;line-height: 40px;padding-left: 15px;color: black;font-size: 20px;" />
				</p>
			</div>
			<button onclick="buy()" style="width: 90%;margin-left: 5%;margin-top:10px;background-color: #008200;color: #fff;height: 45px;line-height: 45px;">确认</button>
		</div>
		<div class="mui-content" id="m2" style="display: none;">

			<div class="mui-content record_content" style="margin: 7px 0px ;background-color: #fff;">

				<p style="margin-left:2%;border-bottom: 1px #CCCCCC solid;height: 45px;line-height:45px;"><em>付款金额</em>
					<em style="float: right;padding-right: 15px;color: black;font-size: 20px;" id="p_money">￥1000</em>
				</p>
				<p style="margin-left:2%;height: 30px;line-height:30px;"><em>合作商</em>
					<em style="float: right;padding-right: 15px;">梦焕光彩郴州服务中心-{$user_info['nick_name']}</em>
				</p>
				<p style="margin-left:2%;height: 30px;line-height:30px;"><em>店铺名称</em>
					<em style="float: right;padding-right: 15px;">梦焕光彩VIP会员-{$user_info['nick_name']}</em>
				</p>
				<p style="margin-left:2%;height: 30px;line-height:30px;"><em>奖励金总额</em>
					<em style="float: right;padding-right: 15px;">480元</em>
				</p>
				<p style="margin-left:2%;height: 30px;line-height:30px;"><em>每天奖励金</em>
					<em style="float: right;padding-right: 15px;">6元</em>
				</p>
				<p style="width:100%;border-top: 1px #CCCCCC solid;border-bottom: 1px #CCCCCC solid;height: 40px;line-height: 40px;">
					<em style="width:50%;text-align: center;float: left;border-right: 1px #CCCCCC solid;" onclick="back()">返回重选</em>
					<em style="width:50%;display: inline-table;text-align: center;float: left;height: 40px;line-height: 40px;color: #009900;" onclick="buy()">确认支付</em>
				</p>
			</div>

		</div>
	</body>

</html>
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/static/layui/layui.all.js"></script>
<script>
	function back() {
		$("#m1").show();
		$("#m2").hide();
	}

	function qr() {
		var hbmoney = $("#hbmoney").val();

		var o = $(this);
		if(hbmoney == "") {
			layer.msg('请输入付款金额');
			return;
		}

		if(hbmoney < 998) {
			layer.msg('付款金额不能少于998!');
			return;
		}
		$("#m2").show();
		$("#m1").hide();
		$("#p_money").text("￥" + $("#hbmoney").val());
	}
	buy();
	function buy() {

		$.ajax({
			type: "post",
			data: {
				money: $("#hbmoney").val(),
				fromuid: "{$fromuid}"
			},
			url: "/index/payment/sk_pay",
			success: function(data) {
				data = JSON.parse(data);
				callpay(data);
			}
		});
	}
	//调用微信JS api 支付
	function jsApiCall(jsApiParameters) {
		WeixinJSBridge.invoke('getBrandWCPayRequest', jsApiParameters,
			function(res) {
				if(res.err_msg == "get_brand_wcpay_request:ok") {
					layer.msg('支付成功', {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						 window.location = "/index/member"; 
					}); 
				} else {
					layer.msg("支付失败")
				}
				
			}
		);
	}

	function callpay(jsApiParameters) {
		if(typeof WeixinJSBridge == "undefined") {
			if(document.addEventListener) {
				document.addEventListener('WeixinJSBridgeReady', jsApiCall(jsApiParameters), false);
			} else if(document.attachEvent) {
				document.attachEvent('WeixinJSBridgeReady', jsApiCall(jsApiParameters));
				document.attachEvent('onWeixinJSBridgeReady', jsApiCall(jsApiParameters));
			}
		} else {
			jsApiCall(jsApiParameters);
		}
	}
</script>